AC_SUBST([LIBEX_dir],[])
AC_SUBST([LIBEX_include],[])
AC_SUBST([LIBEX_libs],[])
AC_SUBST([LIBBANCOPG_dir],[])
AC_SUBST([LIBBANCOPG_include],[])
AC_SUBST([LIBBANCOPG_libs],[])
AC_SUBST([LIBBANCOMY_dir],[])
AC_SUBST([LIBBANCOMY_include],[])
AC_SUBST([LIBBANCOMY_libs],[])
AC_SUBST([LIBHPDF_dir],[])
AC_SUBST([LIBHPDF_include],[])
AC_SUBST([LIBHPDF_libs],[])
#Seleção do modo de Compilação
# --with-dinamico
AC_ARG_WITH(dinamico,
  [AS_HELP_STRING([--with-dinamico],[Compilação Dinâmica])
  ],
  [ ],
  [with_dinamico=yes]
)
#LIBEX
AC_DEFUN([LIBEX],[
AC_SUBST([LIBEX_dir], ['libex'])
AC_SUBST([LIBEX_include], ['-I$(top_srcdir)/libex/src '])
AC_SUBST([LIBEX_libs], ['$(top_srcdir)/libex/src/libex-1.0.a'])
])
#POSTGRESQL
AC_DEFUN([LIBBANCOPG],[
AC_CHECK_PROGS([PG_CONFIG], [pg_config], [/usr/bin/pg_config], [$PATH:/usr/local/pgsql/bin:/usr/pgsql/bin])
if test x"$PG_CONFIG" = x; then
    AC_MSG_ERROR([$PACKAGE requires pg_config])
fi
AC_SUBST([PG_LIBS],  [`$PG_CONFIG --libdir`])
AC_SUBST([PG_CFLAGS],  [`$PG_CONFIG --cflags`])
AC_SUBST([PG_CPPFLAGS],  [`$PG_CONFIG --cppflags`])
AC_SUBST([PG_LDFLAGS], [`$PG_CONFIG --ldflags`])
AC_SUBST([PG_INCLUDE], [`$PG_CONFIG --includedir`])
AC_SUBST([LIBBANCOPG_dir],['libbancopg'])
AC_SUBST([LIBBANCOPG_include],['-I$(top_srcdir)/libbancopg/src -I$(PG_INCLUDE)'])
AC_MSG_CHECKING([Identificando modo de compilação: ])
if test "x$with_dinamico" = "xyes"; then
	AC_SUBST([LIBBANCOPG_libs],['$(top_srcdir)/libbancopg/src/libbancopg-2.0.a -L$(PG_LIBS) -lpq -lssl'])
    AC_MSG_RESULT([Dinâmica])
	break;
else
	AC_SUBST([LIBBANCOPG_libs],['$(top_srcdir)/libbancopg/src/libbancopg-2.0.a $(PG_LIBS)/libpq.a -lssl'])
	AC_MSG_RESULT([Estática])
fi
])
#MYSQL
AC_DEFUN([LIBBANCOMY],[
AC_CHECK_PROGS([MY_CONFIG], [mysql_config], [/usr/bin/mysql_config], [$PATH:/usr/local/mysql/bin:/usr/mysql/bin])
if test x"$MY_CONFIG" = x; then
	AC_MSG_ERROR([$PACKAGE requires mysql_config])
fi
AC_SUBST([MY_LIBS],[`$MY_CONFIG --libs`])
AC_SUBST([MY_CFLAGS],[`$MY_CONFIG --cflags`])
AC_SUBST([LIBBANCOMY_dir],['libbancomy'])
AC_SUBST([LIBBANCOMY_include],['-I$(top_srcdir)/libbancomy/src $(MY_CFLAGS)'])
AC_SUBST([LIBBANCOMY_libs],['$(top_srcdir)/libbancomy/src/libbancomy-1.0.a $(MY_LIBS)'])
])
#HARU
AC_DEFUN([LIBHPDF],[
STANDARD_PREFIXES="/usr /usr/local /opt /local /mingw"

# --with-libdir
AC_ARG_WITH(libdir,
  [AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
  ],
  [LIBDIR=$with_libdir],
  [LIBDIR=lib]
)

# --with-zlib
AC_ARG_WITH(zlib,
  [AS_HELP_STRING([--with-zlib],[specify Zlib install prefix])
  ],
  [ ],
  [with_zlib=yes]
)

if test "x$with_zlib" = "xno"; then
  AC_DEFINE([HAVE_NOZLIB], [], [zlib is not available])
else
  AC_MSG_CHECKING([Zlib install prefix])

  if test "x$with_zlib" = "xyes"; then
    for i in `echo "$STANDARD_PREFIXES"`; do
      if test -f "$i/include/zlib.h"; then
        ZLIB_DIR="$i"
        break;
      fi
    done
  else
    if test -f "$with_zlib/include/zlib.h"; then
      ZLIB_DIR="$with_zlib"
      break;
    else
      AC_MSG_ERROR([Can't find Zlib headers under $with_zlib directory]);
    fi
  fi

  if test "x$ZLIB_DIR" = "x"; then
    AC_MSG_ERROR([Unable to locate Zlib headers, please use --with-zlib=<DIR>]);
  fi

  AC_MSG_RESULT([$ZLIB_DIR])
  LDFLAGS="$LDFLAGS -L$ZLIB_DIR/$LIBDIR"
  CFLAGS="$CFLAGS -I$ZLIB_DIR/include"
  LIBS="$LIBS -lz"
  ZLIBA="$ZLIB_DIR/$LIBDIR/libz.a"
  AC_SUBST([ZLIBA])

  AC_CHECK_LIB([z], [deflate], [], [
    AC_MSG_ERROR([deflate() is missing, check config.log for more details])
  ])

  HAVE_ZLIB=yes
fi
AC_SUBST([LIBHPDF_dir],['libhpdf'])
AC_SUBST([LIBHPDF_include],['-I$(top_srcdir)/libhpdf/include'])
AC_SUBST([LIBHPDF_libs],['$(top_srcdir)/libhpdf/src/libhpdf.a $(ZLIBA) -lpng'])
])
AC_DEFUN([CHECK_OS],[
#Testando plataforma
AC_MSG_NOTICE([Plataforma: $host_os])
case "$host_os" in
	linux*)
		WIN_LD=""
		;;
	*)
		WIN_LD="-mwindows"
		;;
esac
AC_SUBST([WIN_LD])
])
AC_SUBST([INCLUIR])
AC_SUBST([BIBLIOTECA])